package com.trkj.controller;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.service.YzrDrawService;
import com.trkj.vo.Result;
import com.trkj.vo.YzrMedDrawDetVo;
import com.trkj.vo.YzrMedDrawVo;

@Controller
public class YzrDrawController {

	@Autowired
	private YzrDrawService yzrDrawService;
	
	@RequestMapping("to_yzrDraw")
	public String toDraw(){
		return "yzr_draw";
	}
	
	//查询所有的提领单
	@RequestMapping("/queryAllDrawYzr")
	public @ResponseBody Map<String, Object> queryAllDraw(int page, int rows){
		Map<String, Object> map = yzrDrawService.queryAllDraw(page, rows);
		return yzrDrawService.queryAllDraw(page, rows);
	}
	
	//提交提领单的数据到数据库
	@RequestMapping("/addMedDrawYzr")
	public @ResponseBody Result addMedDraw(YzrMedDrawDetVo medDrawList, String zdr, String spr, 
													String stored, String pharmacy){
		yzrDrawService.addMedDraw(medDrawList, zdr, spr, stored, pharmacy);
		return new Result();
	}
	
	//根据提领id查看提领单
	@RequestMapping("/queryDrawByIdYzr")
	public @ResponseBody YzrMedDrawVo queryDrawById(String medDrawId){
		return yzrDrawService.queryDrawById(medDrawId);
	}
	
	
	//根据提领id查看提领详情单
	@RequestMapping("/queryDrawDetByIdYzr")
	public @ResponseBody Map<String, Object> queryDrawDetById(int page, int rows, String medDrawId){
		return yzrDrawService.queryDrawDetById(page, rows, medDrawId);
	}
	
	//各种条件查询
	@RequestMapping("/queryDrawByIfYzr")
	public @ResponseBody Map<String, Object> queryDrawByIf(int page, int rows, String name,String value){		
		return yzrDrawService.queryByIf(page, rows, name, value);
	}
	
	//根据交货时间段查询订单
	@RequestMapping("/queryByDrawDateYzr")
	public @ResponseBody Map<String, Object> queryByDrawDate(Date startDate,Date endDate,int page, int rows){
		return yzrDrawService.queryByDrawDate(startDate, endDate, page, rows);
	}
	
	//根据当然登录用户查出由该用户审批的提领单
	@RequestMapping("/queryDrawByStaffIdYzr")
	public @ResponseBody Map<String, Object> queryDrawByStaffId(int page, int rows, String staffId){
		return yzrDrawService.queryDrawByStaffId(page, rows, staffId);
	}
	
	//审批提领单
	@RequestMapping("/shenpiDrawYzr")
	public @ResponseBody Result shenpiDraw(String shenpiState, String drawId){
		yzrDrawService.shenpiDraw(shenpiState, drawId);
		return new Result();
	}
	
}
